package main

import (
	"fmt"
	"log"
	"net/http"
)

//包装 log
func logging(f http.HandlerFunc) http.HandlerFunc {
	return func(writer http.ResponseWriter, request *http.Request) {
		log.Println(request.URL)
		f(writer, request)
	}
}

func main() {
	http.HandleFunc("/foo", logging(foo))
	http.HandleFunc("/bar", logging(bar))
	http.ListenAndServe(":8989", nil)
}
func foo(writer http.ResponseWriter, request *http.Request) {
	fmt.Fprintf(writer, "fooooo")
}
func bar(writer http.ResponseWriter, request *http.Request) {
	fmt.Fprintf(writer, "barrrrr")
}
